'use strict';

lambApp.factory('settings', ['$rootScope', function ($rootScope) {
  var settings = {
    layout: {
      pageAutoScrollOnLoad: 1000 // auto scroll to top on page load
    },
    layoutImgPath: Metronic.getAssetsPath() + 'admin/layout/img/',
    layoutCssPath: Metronic.getAssetsPath() + 'admin/layout/css/'
  };
  $rootScope.settings = settings;
  return settings;
}]);

lambApp.factory("loginService", ["$http", "$state", function ($http, $state) {
  var loginInfo = {};
  loginInfo.isLogin = false;
  loginInfo.user = null;
  loginInfo.login = function (data) {
    this.isLogin = true;
    this.user = data;
  };
  loginInfo.logout = function () {
    this.isLogin = false;
    this.user = null;
  };
  loginInfo.verifyLogin = function (toState,toParams) {
    var $this = this;
    $http.get(basePath + "login/isLogin.json")
      .success(function (data) {
        if (data.ok) {
          $this.login(data.returnData.user);
          $state.go(toState.name,toParams);
        }
        if (data.error) {
          $state.go('login');
        }
      });

  };
  return loginInfo
}]);

